from datetime import datetime
from typing import Optional
from pydantic import BaseModel, ConfigDict


class PayOrderBase(BaseModel):
    order_no: str
    order_type: int
    merc_order_no: str
    pay_type: int
    merc_no: str
    factor_no: Optional[str]
    amount: int
    fee: int
    status: int

    model_config = ConfigDict(
        #strict=True,
        from_attributes=True
    )

class PayOrder(PayOrderBase):
    up_chn_order_no: Optional[str]
    up_chn_merc_no: Optional[str]
    pay_chn_code: Optional[str]
    pay_chn_name: Optional[str]
    up_chn_error_msg: Optional[str]
    create_time: Optional[datetime]
    update_time: Optional[datetime]

class InitPayOrder(BaseModel):
    merc_no: str
    merc_order_no: str
    bank_code: str
    order_type: int
    amount: int
    user_type: str
    card_type: str
    counter_acc_no: str
    counter_acc_name: str
    currency: str
    

    model_config = ConfigDict(
        #strict=True,
        from_attributes=True
    )

class FeOrderParam(BaseModel):
    '''前置交易参数'''
    amount: str
    bank_code: str
    user_type: str
    card_type: str
    counter_acc_no: str
    counter_acc_name: str
    currency: str
    order_no: str
    inter_bank_flag: str
    cert_type: Optional[str] = None
    cert_no: Optional[str] = None
    

    model_config = ConfigDict(
        #strict=True,
        from_attributes=True
    )

class NewPayOrder(BaseModel):
    order_type: int
    merc_no: str
    factor_no: str
    amount: int

    model_config = ConfigDict(
        #strict=True,
        from_attributes=True
    )

class QueryOrderStatus(BaseModel):
    tranDate: str
    origTranDate: str
    rqsSeqNo: int = 0
    oldPayChannelSeqNo: Optional[str]
    oldAskSysRplSqlNo: Optional[str]
